﻿using FirstHomeWork.Model;
using System;
using System.Collections.Generic;
using System.Linq;

namespace FirstHomeWork.Interface
{
    public interface IDBHelper
    {
        /// <summary>
        /// 无参查询全部数据集合
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        List<T> Query<T>() where T : BaseModel, new();

        /// <summary>
        /// 根据参数查询单个实体对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        T Find<T>(int id) where T : BaseModel, new();

        /// <summary>
        /// 添加实体信息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <returns></returns>
        bool Add<T>(T t) where T : BaseModel, new();

        /// <summary>
        /// 修改实体信息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <returns></returns>
        bool Update<T>(T t) where T : BaseModel, new();

        /// <summary>
        /// 根据主键编号删除实体信息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        bool Delete<T>(int id) where T : BaseModel, new();
    }
}
